package ca.cbc.medialib.service;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;

import org.hibernate.mapping.Set;

public class PrintEntityUtil {

    public static void print(Object obj) {
        Class<?> c = obj.getClass();

        Method[] allMethods = c.getDeclaredMethods();
        for (Method m : allMethods) {
            if (m.getName().startsWith("get") && m.getReturnType() != List.class && m.getReturnType() != Set.class) {
                try {
                    System.out.println(m.getName() + ": " + m.invoke(obj, null));
                } catch (IllegalArgumentException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }
}
